﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class StartController : MonoBehaviour
{
    public Text textCom;

    public float transSceneTime = 2f;
    public float textShowTime = 1.5f;

    private bool isTransScened = false;
    private float timeCount = 0f;

    // Start is called before the first frame update
    void Start()
    {
        Color color = textCom.color;
        color.a = 0f;
        textCom.color= color;
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if(timeCount < textShowTime)
        {
            Color color = textCom.color;
            color.a = timeCount / textShowTime;
            if(Math.Abs(1 - color.a) < 0.1)
            {
                color.a = 1;
            }
            textCom.color= color;
            timeCount += Time.deltaTime;
        }
        else if(timeCount < textShowTime + transSceneTime)
        {
            timeCount += Time.deltaTime;
        }
        else
        {
            if(!isTransScened)
            {
                isTransScened = true;
                SceneHelper.LoadScene("home");
            }
        }
    }
}
